package com.dk.service.impl;


import com.dk.mapper.GameMapper;
import com.dk.pojo.Game;
import com.dk.service.GamesService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class GamesServiceImpl implements GamesService {
    @Autowired
    private GameMapper gameMapper;

    @Override
    public List<Game> getInfo() {
        return gameMapper.selectByExample(null);
    }

    @Override
    public PageInfo<Game> show(Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
        List<Game> list = gameMapper.selectByExample(null);
        PageInfo<Game> page = new PageInfo<>(list);
        return page;
    }

    @Override
    public boolean addInfo(Game game) {
        return gameMapper.insert(game) > 0;
    }

    @Override
    public boolean deleteInfo(Integer id) {
        return gameMapper.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public Game toUpdatet(Integer id) {
        return gameMapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean updateInfo(Game game) {
        return gameMapper.updateByPrimaryKey(game) > 0;
    }
}
